package utils;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.LinearLayout;

import interfaces.MyCallBack;

/**
 * Created by zhaoshengping on 2017/2/26.
 */

public abstract class QrEdit {
    private LinearLayout linearLayout;
    private Context mContext;
    public MyCallBack callBack;
    public QrEdit () {}

    public QrEdit (Context context, LinearLayout linearLayout) {
        this.linearLayout = linearLayout;
        this.mContext = context;
    }

    public void showDialog () {
        AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
        bindView();
        dialog.setTitle("编辑二维码");
        dialog.setIcon(null);
        dialog.setView(linearLayout);
        dialog.setPositiveButton("确定", confirmClick());
        dialog.setNegativeButton("取消",null);
        dialog.show();
    }

    private DialogInterface.OnClickListener confirmClick() {
        return new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                sureClick();
            }
        };
    }

    public void setSureCallBack (MyCallBack callback) {
        this.callBack = callback;
    }

    public abstract void bindView ();

    public abstract void sureClick ();
}
